#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

// 播放器状态枚举
typedef NS_ENUM(NSInteger, ZJPlayerState) {
    ZJPlayerStateUnknown,
    ZJPlayerStatePlaying,
    ZJPlayerStatePaused,
    ZJPlayerStateBuffering,
    ZJPlayerStatePlayEnd,
    ZJPlayerStateError
};

// 代理协议
@protocol ZJVideoPlayerDelegate <NSObject>
@optional
- (void)videoPlayer:(id)player currentTime:(NSTimeInterval)currentTime totalTime:(NSTimeInterval)totalTime;
- (void)onlyOnceVideoPlayer:(id)player totalTime:(NSTimeInterval)totalTime;

- (void)videoPlayer:(id)player playerStateChanged:(ZJPlayerState)state;
- (void)videoPlayer:(id)player didFailWithError:(NSError *)error;
- (void)videoPlayerDidReadyToPlay:(id)player;
- (void)videoPlayerBufferingStateChanged:(id)player isBuffering:(BOOL)isBuffering;

@end

@interface ZJVideoPlayerManager : NSObject

@property (nonatomic, weak) id<ZJVideoPlayerDelegate> delegate;
@property (nonatomic, readonly) ZJPlayerState currentState;
@property (nonatomic, readonly) float progress;
@property (nonatomic, readonly) NSTimeInterval currentTime;
@property (nonatomic, readonly) NSTimeInterval totalTime;
@property (nonatomic, assign) BOOL isLooping; // 循环播放
@property (nonatomic, assign) float volume;    // 音量控制

+ (instancetype)shared;

// 在指定视图上播放视频
- (void)playVideoWithUrl:(NSString *)videoUrl onView:(UIView *)containerView;

// 暂停播放
- (void)pause;

// 继续播放
- (void)resume;

// 停止播放
- (void)stop;

// 释放播放器
- (void)destroyPlayer;

// 新增方法
- (void)seekToTime:(NSTimeInterval)time;
- (void)setMuted:(BOOL)muted;
- (void)setPlaybackRate:(float)rate;
- (UIImage *)thumbnailImageAtCurrentTime;
- (void)configurePlayerWithOptions:(NSDictionary *)options;

@end

NS_ASSUME_NONNULL_END 
// ZJVideoPlayerManager *playerManager = [ZJVideoPlayerManager shared];
// playerManager.delegate = self;

// // 配置播放器
// [playerManager configurePlayerWithOptions:@{
//     @"volume": @(0.8),
//     @"isLooping": @YES
// }];

// // 开始播放
// [playerManager playVideoWithUrl:videoUrl onView:self.videoView];

// // 设置播放速率
// [playerManager setPlaybackRate:1.5];

// // 获取当前帧缩略图
// UIImage *thumbnail = [playerManager thumbnailImageAtCurrentTime];
